package com.hmall.common.client;

import com.hmall.common.dto.PageDTO;
import com.hmall.common.pojo.Item;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(value = "itemservice",path = "/item")
//@FeignClient(value = "itemservice",path = "/item",configuration = FeignConfig.class)
public interface ItemClient {

    /**
     * 商品分页查询
     *
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/list")
    PageDTO<Item> queryPage(@RequestParam("page") Integer page, @RequestParam("size") Integer size);

    /**
     * 根据ID查询商品
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    Item getById(@PathVariable("id") Long id);

    /**
     * 增减商品库存
     *
     * @param ItemId
     * @param num
     */
    @PutMapping("/stock/{itemId}/{num}")
    void updateStock(@PathVariable("itemId") Long ItemId,@PathVariable("num") Integer num);
}
